package com.kx.core.dawn.dbs.dao;

import com.kx.core.dawn.dbs.dao.impl.*;
import com.kx.game.center.dbs.DBServices;

public class DaoManager {

    public static GameServerDao gameServerDao = new GameServerDao();

    public static GatewayDao gatewayDao = new GatewayDao();

    public static UserDao userDao = new UserDao();

    public static RoleDao roleDao = new RoleDao();

    public static RoleExtraDao roleExtraDao = new RoleExtraDao();

    public static void initTable(String serverId) {
//        if (!existTable(serverId, "User_Info"))
//            DBServices.getDBConntion(serverId).update("User_Info" + ".createTable");
        if (!existTable(serverId, "Game_Server"))
            DBServices.getDBConntion(serverId).update("Game_Server" + ".createTable");
        if (!existTable(serverId, "Gateway"))
            DBServices.getDBConntion(serverId).update("Gateway" + ".createTable");
    }

    public static boolean existTable(String serverId, String tableName) {
        int integer = (int) DBServices.getDBConntion(serverId).selectOne("Base_Info" + ".existTable", tableName);
        return integer != 0;
    }

}
